package cn.org.tpeach.nosql;

import cn.org.tpeach.nosql.annotation.ComponentScan;
import cn.org.tpeach.nosql.annotation.JFrameMain;
import cn.org.tpeach.nosql.constant.PublicConstant;
import cn.org.tpeach.nosql.enums.LogType;
import cn.org.tpeach.nosql.enums.MsgType;
import cn.org.tpeach.nosql.framework.BaseApp;
import cn.org.tpeach.nosql.framework.LarkFrame;
import cn.org.tpeach.nosql.framework.LogMsg;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.UnsupportedEncodingException;

@ComponentScan(basePackages = { "cn.org.tpeach.nosql.service","cn.org.tpeach.nosql.redis.connection", "cn.org.tpeach.nosql.redis.service" })
@JFrameMain("cn.org.tpeach.nosql.controller.RedisApplication")
@Slf4j
public class Application  extends BaseApp {

	public static void main(String[] args) {
		LarkFrame.run(Application.class, args);
	}

	@Override
	public String getConfigPath() {
		String path = Application.class.getProtectionDomain().getCodeSource().getLocation().getPath();
		try {
			path = java.net.URLDecoder.decode(path, PublicConstant.CharacterEncoding.UTF_8);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		if (System.getProperty("os.name").contains("dows")) {
			path = path.substring(1, path.length());
		}
		if (path.contains("jar")) {
			path = path.substring(0, path.lastIndexOf(".")).substring(0, path.lastIndexOf("/"));
		}else{
			path = path.replace("target/classes/", "");
		}
		return path+ File.separator+".RedisLettuceClient.conf";
	}
}
